package com.easyadmin.modules.stock.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.easyadmin.common.web.domain.request.PageDomain;
import com.easyadmin.modules.stock.domain.SysStockIndustryDay;
import com.easyadmin.modules.stock.mapper.SysStockIndustryDayDao;
import com.easyadmin.modules.stock.service.SysStockIndustryDayServer;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service("sysStockIndustryDayServer")
public class SysStockIndustryDayServerImpl extends ServiceImpl<SysStockIndustryDayDao, SysStockIndustryDay>
        implements SysStockIndustryDayServer {

    @Resource
    SysStockIndustryDayDao sysStockIndustryDayDao;

    @Override
    public PageInfo<SysStockIndustryDay> queryPage(SysStockIndustryDay sysStockIndustry, PageDomain pageDomain) {
        PageHelper.startPage(pageDomain.getPage(), pageDomain.getLimit());
        List<SysStockIndustryDay> data =sysStockIndustryDayDao.selectList(new QueryWrapper<SysStockIndustryDay>().lambda()
                .like(StringUtils.isNotBlank(sysStockIndustry.getIndustryName()),
                        SysStockIndustryDay::getIndustryName,sysStockIndustry.getIndustryName())
                .like(StringUtils.isNotBlank(sysStockIndustry.getIndustryCode()),
                        SysStockIndustryDay::getIndustryCode,sysStockIndustry.getIndustryCode()));
        return new PageInfo<>(data);
    }

    @Override
    public Boolean remove(String id) {
        sysStockIndustryDayDao.deleteById(Integer.valueOf(id));
        return true;
    }

    @Override
    public boolean update(SysStockIndustryDay sysFuturesEntity) {
        Integer result = sysStockIndustryDayDao.updateById(sysFuturesEntity);
        return result > 0;
    }

    @Override
    public boolean batchRemove(String[] ids) {
        for(String  id:ids){
            sysStockIndustryDayDao.deleteById(id);
        }
        return true;
    }


}




